﻿using ElencySolutions.MultipleProperty.Configuration;

namespace ElencySolutions.MultipleProperty
{
    using System;

    /// <summary>
    /// Multiple property entity attribute
    /// </summary>
    public class MultiplePropertyEntityAttribute : Attribute
    {

        #region Members

        private int _maximumNumberOfEntities;
        private int _minimumNumberOfEntities;
        private bool _copyAsNew;
        private bool _copyAsNewSet;
        private bool _allowPropertyCopying;
        private bool _allowPropertyCopyingSet;
        private bool _allowEdit = true;
        private bool _allowDelete = true;
        private bool _allowAdd = true;
        private bool _allowSort = true;

        #endregion Members

        #region Properties

        /// <summary>
        /// Gets or sets the maximum number of entities.
        /// </summary>
        /// <value>
        /// The maximum number of entities.
        /// </value>
        public int MaximumNumberOfEntities
        {
            get 
            { 
                return _maximumNumberOfEntities; 
            }
            set
            {
                MaximumNumberOfEntitiesSet = true;
                _maximumNumberOfEntities = value;
            }
        }

        /// <summary>
        /// Gets or sets the minimum number of entities.
        /// </summary>
        /// <value>
        /// The minimum number of entities.
        /// </value>
        public int MinimumNumberOfEntities
        {
            get
            {
                return _minimumNumberOfEntities;
            }
            set
            {
                MinimumNumberOfEntitiesSet = true;
                _minimumNumberOfEntities = value;
            }
        }

        /// <summary>
        /// Gets or sets the list item information header.
        /// </summary>
        /// <value>
        /// The list item information header.
        /// </value>
        public string ListItemInformationHeader { get; set; }

        /// <summary>
        /// Gets or sets the list item information header translation key.
        /// </summary>
        /// <value>
        /// The list item information header translation key.
        /// </value>
        public string ListItemInformationHeaderTranslationKey { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [allow null entities].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [allow null entities]; otherwise, <c>false</c>.
        /// </value>
        public bool AllowNullEntities { get; set; }

        /// <summary>
        /// Gets or sets the add button text.
        /// </summary>
        /// <value>
        /// The add button text.
        /// </value>
        public string AddButtonText { get; set; }

        /// <summary>
        /// Gets or sets the add button text translation key.
        /// </summary>
        /// <value>
        /// The add button text translation key.
        /// </value>
        public string AddButtonTextTranslationKey { get; set; }

        /// <summary>
        /// Gets or sets a value indicating whether [allow property copying].
        /// </summary>
        /// <value>
        /// <c>true</c> if [allow property copying]; otherwise, <c>false</c>.
        /// </value>
        public bool AllowPropertyCopying
        {
            get
            {
                return _allowPropertyCopyingSet ? _allowPropertyCopying : MultiplePropertyConfiguration.GetConfiguration().AllowPropertyCopyingDefault;
            }
            set
            {
                _allowPropertyCopying = value;
                _allowPropertyCopyingSet = true;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [add copy as new button].
        /// </summary>
        /// <value>
        /// 	<c>true</c> if [add copy as new button]; otherwise, <c>false</c>.
        /// </value>
        public bool AddCopyAsNewButton
        {
            get
            {
                return _copyAsNewSet ? _copyAsNew : MultiplePropertyConfiguration.GetConfiguration().CopyAsNewDefault;
            }
            set 
            { 
                _copyAsNew = value;
                _copyAsNewSet = true;
            }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [allow add].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [allow add]; otherwise, <c>false</c>.
        /// </value>
        public bool AllowAdd
        {
            get { return _allowAdd; }
            set { _allowAdd = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [allow delete].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [allow delete]; otherwise, <c>false</c>.
        /// </value>
        public bool AllowDelete
        {
            get { return _allowDelete; }
            set { _allowDelete = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [allow edit].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [allow edit]; otherwise, <c>false</c>.
        /// </value>
        public bool AllowEdit
        {
            get { return _allowEdit; }
            set { _allowEdit = value; }
        }

        /// <summary>
        /// Gets or sets a value indicating whether [allow sort].
        /// </summary>
        /// <value>
        ///   <c>true</c> if [allow sort]; otherwise, <c>false</c>.
        /// </value>
        public bool AllowSort
        {
            get { return _allowSort; }
            set { _allowSort = value; }
        }

        internal bool MaximumNumberOfEntitiesSet { get; set; }
        internal bool MinimumNumberOfEntitiesSet { get; set; }

        #endregion Properties

    }
}
